package org.linlinjava.litemall.wx.web;

import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.service.LitemallGoodsProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("/wx/goodsProduct")
public class WxGoodsProductController {
    @Autowired
    private LitemallGoodsProductService goodsProductService;

    /**
     * 获取可租借得书列表
     *
     * @param bookName
     * @param page
     * @param limit
     * @param sort
     * @param order
     * @return
     */
    @GetMapping("/listBorrowBooks")
    public Object listBorrowBooks(String bookName,
                                  @RequestParam(required = false, defaultValue = "1") Integer page,
                                  @RequestParam(required = false, defaultValue = "10") Integer limit,
                                  @RequestParam(required = false, defaultValue = "book_order_by") String sort,
                                  @RequestParam(required = false, defaultValue = "desc") String order) {
        return ResponseUtil.ok(goodsProductService.queryByOldAndCategoryCanBorrowed(bookName, page - 1, limit, sort, order));
    }
}
